composer_install_inline.php

<?php
/**
 * Print a `composer require` statement for the current branch of your repo.
 *
 * @usage `@\template(php/composer_install_inline, ?composer_package_name, ?branch_name, ?flags)`, `@\template(composer_install)`, or `@\template(composer_install, taeluf/code-scrawl, v0.8.x-dev, --dev)`. To use defaults, leave the argument blank: `@template(php/composer_install_inline,,,--dev)`
 *
 * @param $args[0] (optional) package name like `taeluf/code-scrawl` ... defaults to name declared in composer.json
 * @param $args[1] (optional) branch name ... defaults to current branch
 * @param $args[2] (optional) flags string to append to the composer require command
 */

$package = empty($args[0]) ? \Tlf\Scrawl\Utility\Main::getComposerPackageName() : $args[0];
if ($package==null){
    $this->warn("composer.json file not found","Cannot find composer.json file at ".getcwd().'/composer.json, nor was package name passed to @template(composer_install, vendor/package)');
    echo "--cannot print composer install instructions because package name was not passed--";
    return;
}
$version = empty($args[1]) ? \Tlf\Scrawl\Utility\Main::getCurrentBranchForComposer() : $args[1];

$flags = empty($args[2]) ? '' : ' '.$args[2];

echo "`composer require $package $version$flags`";